]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
dateMenu: Do not ellipsize date header
authorFlorian Müllner <fmuellner@gnome.org>
Thu, 24 Sep 2020 02:46:47 +0000 (04:46 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Fri, 25 Sep 2020 10:00:40 +0000 (12:00 +0200)
Currently the width of the calendar column is solely determined
by the calendar, while other elements are ellipsized as necessary.

While that is the desired behavior for the events-, world clocks-
and weather sections, we don't want to cut off the date in the
header. However switching to bold text made that more likely in
non-English locales or when using large text, so explicitly take
it into account for the width negotiation.

https://gitlab.gnome.org/GNOME/gnome-shell/-/issues/2230

js/ui/dateMenu.js

index 13d1d4019dc7ac9c00b19f214aa862083f3382b0..993d49289697bc205ad3c0ced15c5ca992f201bc 100644 (file)
@@ -762,15 +762,20 @@ class FreezableBinLayout extends Clutter.BinLayout {
 
 var CalendarColumnLayout = GObject.registerClass(
 class CalendarColumnLayout extends Clutter.BoxLayout {
-    _init(actor) {
+    _init(actors) {
         super._init({ orientation: Clutter.Orientation.VERTICAL });
-        this._calActor = actor;
+        this._colActors = actors;
     }
 
     vfunc_get_preferred_width(container, forHeight) {
-        if (!this._calActor || this._calActor.get_parent() != container)
+        const actors =
+            this._colActors.filter(a => a.get_parent() === container);
+        if (actors.length === 0)
             return super.vfunc_get_preferred_width(container, forHeight);
-        return this._calActor.get_preferred_width(forHeight);
+        return actors.reduce(([minAcc, natAcc], child) => {
+            const [min, nat] = child.get_preferred_width(forHeight);
+            return [Math.max(minAcc, min), Math.max(natAcc, nat)];
+        }, [0, 0]);
     }
 });
 
@@ -821,6 +826,7 @@ class DateMenuButton extends PanelMenu.Button {
             layout.frozen = !_isToday(date);
             this._eventsItem.setDate(date);
         });
+        this._date = new TodayButton(this._calendar);
 
         this.menu.connect('open-state-changed', (menu, isOpen) => {
             // Whenever the menu is opened, select today
@@ -837,15 +843,13 @@ class DateMenuButton extends PanelMenu.Button {
         hbox.add_child(this._messageList);
 
         // Fill up the second column
-        let boxLayout = new CalendarColumnLayout(this._calendar);
+        const boxLayout = new CalendarColumnLayout([this._calendar, this._date]);
         vbox = new St.Widget({ style_class: 'datemenu-calendar-column',
                                layout_manager: boxLayout });
         boxLayout.hookup_style(vbox);
         hbox.add(vbox);
 
-        this._date = new TodayButton(this._calendar);
         vbox.add_actor(this._date);
-
         vbox.add_actor(this._calendar);
 
         this._displaysSection = new St.ScrollView({ style_class: 'datemenu-displays-section vfade',